import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import*
testCase="DBshop006_删除订单"

orderID=readFile(r"..\public\orderID.txt")


dr=openBrowser(urlAdmin)
DBshopLoginAdmin(dr)
# 1.点击销售管理订单管理界面。
DBshopEnterMenu2(dr,"销售管理","订单管理")
s=dr.find_element_by_xpath("//body").text
l="订单数\："
r="\)"
num1=reGetString(s,l,r)
time.sleep(2)
# 2.在订单号查询框输入orderID，点击“搜索”按钮。
DBshopSearchOrderID(dr,orderID)
# 3.勾选，点击删除
dr.find_element_by_name("order_id[]").click()
dr.find_element_by_xpath('//option[text()="删除"]').click()
dr.find_element_by_xpath('//button[contains(.,"提交操作")]').click()
time.sleep(1)
dr.switch_to.alert.accept()
time.sleep(3)

#删除前的订单数=删除后的订单数+1
s=dr.find_element_by_xpath("//body").text
num2=reGetString(s,l,r)
if int(num1)==int(num2)+1: #num2是删除后记录数  num1是删除前的订单数
    writeLog("%s 测试通过" % (testCase))
else:
    writeLog("%s 测试失败" % (testCase))
    getPhoto(dr)
dr.quit()